<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="content-Type" content="text/html;charset=utf-8">
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>

    <meta name="description" content="个人中心"/>
    <title>个人中心</title>
    <link rel="stylesheet" href="css/user-reset.css"/>
    <link rel="stylesheet" href="css/user-main.css"/>
    <link rel="stylesheet" href="css/cookdeal.css"/>
    <script src="js/js.cookie.js" type="application/javascript"></script>
    <script type="text/javascript" src="js/jquery-3.4.1.js"></script>
    <script src="js/jquery.cookie.js"></script>
    <script type="text/javascript">
       var phonenumber;
       var people;
       var flag;
        $(function () {
            var name = $.cookie('ordername');
            var number = $.cookie('phnumber');
            phonenumber=number;
            people=name;
            $.ajax({
                type:"get",
                url:"user/getLogin.do",
                dataType: "json",
                async:false,
                success:function (data) {
                    if(data.result!=0){
                        if($.trim(data.sign)==$.trim("u")){
                            flag=1;
                        }else{
                            flag=0;
                        }
                    }
                }
            })
            if(flag==1){
                $("#orders").empty();
                $.ajax({
                    type: "get",
                    url: "appointment/findAppoint.do",
                    dataType:"json",
                    success:function (data){
                        $.each(data,function (i,n) {
                            $("#orders").append("<div class='section  section2'>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+n.orderid+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+name+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+number+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+n.time+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>" +
                                "<a onclick=''>查看订单详情</a></div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>" +
                                "<input type='button' value='修改信息'>" +
                                "<input type='button' value='撤销申请'>" +
                                "</div>" +
                                "<div class='clear'></div></div>")
                        })
                    }
                })
            }else if(flag==0){
                $("#orders").empty();
                $.ajax({
                    type: "get",
                    url: "appointment/findAppoint.do",
                    dataType:"json",
                    success:function (data){
                        $.each(data,function (i,n) {
                            $("#orders").append("<div class='section  section2'>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+n.orderid+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+name+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+number+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+n.time+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>" +
                                "<a onclick=''>查看订单详情</a></div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>" +
                                "<input type='button' onclick='jieshou()' value='接受'>" +
                                "<input type='button'onclick='' value='拒绝'>" +
                                "</div>" +
                                "<div class='clear'></div></div>")
                        })
                    }
                })
            }else{
                alert("你还未登录，请登录查看订单信息")
                $("#orders").empty();
            }
        })
        function jieshou(){
            if(confirm("您将接单，是否继续")){
                $("#orders").empty();
                $.ajax({
                    type: "get",
                    url: "appointment/findAppoint.do",
                    dataType:"json",
                    success:function (data){
                        $.each(data,function (i,n) {
                            $("#orders").append("<div class='section  section2'>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+n.orderid+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+people+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+phonenumber+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>"+n.time+"</div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>" +
                                "<a onclick=''>查看订单详情</a></div>" +
                                "<div class='margin-right-container-nav margin-right-container-nav2'>" +
                                "<span id='change'>已接单</span>" +
                                "</div>" +
                                "<div class='clear'></div></div>")
                        })
                    }
                })
                return true;
            }else{
                return false;
            }
        }
       function tuichu(){
           $.ajax({
               type:"get",
               url:"user/logout.do",
               dataType:"json",
               success:function (data){
                   if(data.result==1){
                       alert("退出成功");
                       location.href="index.html";
                   }
               }
           })
       }

    </script>
</head>
<!--顾客订单 -->
<body>
<!-- 固定 -->
<div class="main">
    <div class="main-left main-left2">
        <div class="main-left-header">个人中心</div>
        <div class="main-left-nav">

            <div class="main-left-navs main-left-manage navs-active">
                <p class="nav-name" onclick="window.location.href='index.html'">同乡烩首页</p>
                <div class="navs  navs-first" onclick="window.location.href=''">购物车</div>
                <div class="navs" onclick="window.location.href='user-indent.html'">订单</div>
                <div class="navs" onclick="window.location.href='user-data.html'">修改资料</div>
                <div class="navs" onclick="window.location.href='cookdeal.html'">预约信息</div>
                <div class="navs" onclick="tuichu()">退出登录</div>
            </div>


        </div>
    </div>


    <div class="main-left"></div>

    <!-- 操作 -->
    <div class="main-right">
        <div class="main-right-header"></div>
        <div class="main-right-navs">
            <a href="user-index.html">首页</a><a class="split">/</a><a>订单</a>
            <!-- 搜索模块 -->

            <div class="search">

                <input type="text" value="" placeholder="请输入关键词">

                <button></button>

            </div>
        </div>


        <div class="margin-right-container">
            <div class="section section1">
                <div class="margin-right-container-nav">订单号</div>
                <div class="margin-right-container-nav">用户名</div>
                <div class="margin-right-container-nav">电话号码</div>
                <div class="margin-right-container-nav">创建时间</div>
                <div class="margin-right-container-nav">订单详情</div>
                <div class="margin-right-container-nav">操作</div>
                <div class="clear"></div>
            </div>

            <div id="orders">
                <div class="section  section2">
                    <div class="margin-right-container-nav margin-right-container-nav2">18</div>
                    <div class="margin-right-container-nav margin-right-container-nav2">张先生</div>
                    <div class="margin-right-container-nav margin-right-container-nav2">15914924086</div>
                    <div class="margin-right-container-nav margin-right-container-nav2">2020-05-09</div>
                    <div class="margin-right-container-nav margin-right-container-nav2"><a onclick=""></a></div>
                    <div class="margin-right-container-nav margin-right-container-nav2">
                        <span id="change">已接单</span>


                    </div>
                    <div class="clear"></div>
                </div>
            </div>

        </div>

    </div>
    <div class="clear"></div>
</div>

</body>
</html>
